﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head><link rel="stylesheet" href="${ctx}/common/common.css">
    <title>Title</title>
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
    <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>
    
    <script src="${ctx}/common/plugins/publicJs/publicJs.js"></script>
    <style>
        .layui-body{overflow-y: scroll;}
    </style>
</head>
<body>
<!--主体内容层-->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12 layui-col-space15">
            <form>
                <!--输入框内容盒子-->
                <div class="layui-col-md12">
                    <!--输入框-->
                    <div class="layui-col-md3">
                        <label class="layui-form-label">企业名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name"
                                   placeholder="请输入企业名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <!--通用按钮盒子-->
                <div class="layui-col-md12" style="padding-top: 10px;padding-bottom: 10px">
                    <div style="float: right;" class="layui-btn-group paramBtn">
                        <button data-type="reloadProcess" type="button" class="layui-btn layui-btn-sm layui-btn-danger">
                            查询
                        </button>
                        <button data-type="resetProcess" type="reset" class="layui-btn layui-btn-sm layui-btn-danger">
                            重置
                        </button>
                    </div>
                </div>
            </form>

            <table class="layui-table" id="processReload" lay-data="{ url:'${ctx}/findPage?area=${area}', page:true,groups:5}" lay-filter="demo">
                <thead>
                <tr>
                    <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                    <th lay-data="{field:'name',sort:true}">企业名称</th>
                    <th lay-data="{field:'code',sort:true}">营业执照</th>
                    <th lay-data="{field:'contact',sort:true}">联系人</th>
                    <th lay-data="{field:'phone',sort:true}">联系电话</th>
                    <th lay-data="{field:'securityOfficer',sort:true}">安全管理员</th>
                    <th lay-data="{field:'deptName',sort:true}">部门</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
</body>
<script>
    layui.use('table', function () {
    	var loading=layer.msg("数据加载中...");
        var table = layui.table;
        table.render({
            done:function(){
                layer.close(loading);
            }
        })

        var $ = layui.$, active = {
            reloadProcess: function () {//条件查询
                var processName = document.getElementById("name").value;
                table.reload('processReload', {
                    where: {
                    	name: processName
                    }
                });
            },
            resetProcess: function () {
                table.reload('processReload', {
                    where: {
                    	name: '',
                    }
                })
            },


        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //给按钮绑定active中的方法
        $(".paramBtn .layui-btn").on("click", function () {
            var type = $(this).data('type');
            //查看是active这个json中是否有type这个方法，如果有调用，如果没有不知心；
            active[type] ? active[type].call() : '';
        })

    });
</script>
</html>



